package ae;
import java.util.ArrayList;
import java.util.List;

public class Register
{
    private String error = "";
    private List<String[]> data = new ArrayList<String[]>();
    public void Check(String account, String password) throws RegisterException
    {
        if(account.length() < 3 || account.length() > 8)
        {
            error = "该账号" + account + "的长度不合法!";
            throw new RegisterException(error);
        }

        if((!password.matches("\\d*")) || (password.length() < 4 || password.length() > 6))
        {
            error = "输入的密码只能为 4 到 6 位数字!该密码不符合要求!";
            throw new RegisterException(error);
        }
        for(String[] user : data)
        {
            if(account.equals(user[0]))
            {
               error = "该账号" + account + "已经存在于系统中!";
               throw new RegisterException(error);
            }
        }
        data.add(new String[]{account, password});
    }
    public String getError()
    {
        return error;
    }


}
